﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace Ledict.ConditionExtract.BLL
{
  public  class AnalysisInferRuleBLL
    {

      public bool GetExpressionValue (string LogicExpression)
      {
          LogicExpression = LogicExpression.Replace("1", "(1<=11)").Replace("0", "(1>=11)");
          return (bool)new DataTable().Compute(LogicExpression, "");
      }


       public List<string> InferRuleAllTest(string sql)
          {
              List<string> Arr = new List<string>();
              int firs = sql.IndexOf("$");
              if (firs != -1)
              {
                  String value1 = sql.Substring(0, firs);//取出+前面的字符串
                  List<string> value2Arr = InferRuleAllTest(sql.Substring(firs + 1));
                  if (value2Arr.Count > 0)
                  {
                      foreach (var item in value2Arr)
                      {
                          Arr.Add(value1 + "1" + item);
                          Arr.Add(value1 + "0" + item);
                      }
                  }
              }
              else
              {
                  Arr.Add(sql);
              }
              return Arr;
          }


    }
}
